<?php
class ProductController extends AppController {

    public $layout = 'main';

    function beforeFilter() {
        parent::beforeFilter(); 
    }

    function index(){
	    $this->loadModel('Product');
        $this->loadModel('ProductClasse');
        $product=$this->Product->find("all",array('limit'=>9,'order'=>array('id' =>'desc')));
        $productclass=$this->ProductClasse->find("all",array());  
        if(!empty($id)){
            $cates = $this->Product->find('all',array('conditions'=>array('class'=>$id),'limit'=>9,'order'=>array('id' =>'desc')));
        }else{
            $cates = $this->Product->find('all',array('limit'=>9,'order'=>array('id' =>'desc')));
        }
        $this->paginate = array(                                        //利用分页取出数据
            'order'=>array('id' =>'desc'),
            'limit'=>10
        );
        try{
            $case = $this->paginate('Product');
        }catch(NotFoundException $e){
            $case = array();
        }
        $this->set("product",$product); 
        $this->set("productclass",$productclass); 
        $this->set('pro',$cates); 

    }
    function info(){
        $this->loadModel('Product');
        $this->loadModel('ProductClasse');
        $product=$this->Product->find("all",array());
        $productclass=$this->ProductClasse->find("all",array());  
        
        $this->set("product",$product); 
        $this->set("productclass",$productclass); 
    }

}